package com.ztgf.shopping.api.client.epg;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgMainNavigationBO;
import com.ztgf.shopping.models.bo.epg.EpgShowWindowBO;
import com.ztgf.shopping.models.dto.epg.EpgMainNavigationDTO;
import com.ztgf.shopping.models.dto.epg.EpgSectionDTO;
import com.ztgf.shopping.models.dto.epg.EpgShowWindowDTO;
import com.ztgf.shopping.models.service.epg.IEpgShowWindowService;
import com.ztgf.shopping.models.vo.epg.EpgShowWindowVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: chenyu.wang
 * date: 2020-05-19 15:22
 * Description:
 */
@RestController
@RequestMapping("/api/epgShowWindow")
@Slf4j
@Api(value = "EpgShowWindowApiController", tags = "橱窗（新鲜好物）Api接口")
public class EpgShowWindowApiController {

    @DubboReference
    private IEpgShowWindowService showWindowService;
    /**
     * 橱窗（新鲜好物） 根据功能id
     * @param moduleId 功能id
     * @return
     */
    @ApiOperation(value = "橱窗（新鲜好物）列表 根据功能id",notes = "橱窗（新鲜好物）列表 根据功能id")
    @PostMapping("/getListByModuleId")
    public Result<List<EpgShowWindowVO>> getListByModuleId(Long moduleId){
        EpgShowWindowBO epgShowWindowBO = new EpgShowWindowBO();
        epgShowWindowBO.setModuleId(moduleId);
        List<EpgShowWindowVO> epgShowWindowVOList = showWindowService.getBySelectShowWindowInfoNoPage(epgShowWindowBO);
        return new Result<>(epgShowWindowVOList);
    }

    @PostMapping("/getById")
    @ApiOperation(value = "根据id查找", notes = "根据id查找")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    public Result<EpgShowWindowDTO> getById(@RequestParam Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(showWindowService.selectById(id));
    }

    @ApiOperation(value = "橱窗列表", notes = "橱窗列表")
    @PostMapping("/querySelectList")
    public Result<List<EpgShowWindowVO>> querySelectList(EpgShowWindowBO bo) {
        if(null == bo)
            return new Result<>(CodeEnum.FAIL_100002 );
        List<EpgShowWindowVO> epgShowWindowVOList = showWindowService.getBySelectShowWindowInfoNoPage(bo);
        return new Result<>(epgShowWindowVOList);
    }
}
